<template>
  <div>
    <div id="allmap" style="height: 100%;">

    </div>
  </div>
</template>
<script>
import axios from "axios";
import BMap from "BMap";
export default {
  data() {
    return {
      qyCenterPoint: this.$route.query.jwd,
      mapCenterPoint1: "94.683463,40.0996",
      fillOpacity1: "0.08",
      zoom2: "17",
      e: ""
    };
  },
  created() {
    // 该方法用来更改tabbarshow的值 用来 展示、隐藏底部 tabbar (boolean为0 展示、boolean为1 隐藏)
    this.$store.dispatch("showTabbar", { boolean: "1" });
  },
  mounted() {
    this.creatmap();
  },
  updated() {},
  methods: {
    goBack() {
      history.go(-2);
    },
    creatmap() {
      if (this.qyCenterPoint === ''){
          this.qyCenterPoint = this.mapCenterPoint1
      }
      console.log(this.qyCenterPoint);
      let point = this.qyCenterPoint.split(",");
      let x = parseFloat(point[0]);
      let y = parseFloat(point[1]);
      var ggPoint = new BMap.Point(x, y);

      //地图初始化
      var bm = new BMap.Map("allmap");
      bm.centerAndZoom(ggPoint, 15);
      bm.addControl(new BMap.NavigationControl());

      bm.clearOverlays();
      var marker = new BMap.Marker(ggPoint); // 创建标注
      bm.addOverlay(marker); // 将标注添加到地图中
      bm.panTo(ggPoint);

      //添加谷歌marker和label
      // var markergg = new BMap.Marker(ggPoint);
      //bm.addOverlay(markergg); //添加谷歌marker
      //var labelgg = new BMap.Label("", { offset: new BMap.Size(20, -10) });
      // markergg.setLabel(labelgg); //添加谷歌label
      //坐标转换完之后的回调函数
      // function translateCallback(data) {
      //   if (data.status === 0) {
      //     var marker = new BMap.Marker(data.points[0]);
      //     bm.addOverlay(marker);
      //     var label = new BMap.Label("在这里", {
      //       offset: new BMap.Size(20, -10)
      //     });
      //     marker.setLabel(label); //添加百度label
      //     bm.setCenter(data.points[0]);
      //   }
      // }
      // setTimeout(function() {
      //   var convertor = new BMap.Convertor();
      //   var pointArr = [];
      //   pointArr.push(ggPoint);
      //   convertor.translate(pointArr, 3, 5, translateCallback);
      // }, 1000);
    }
  }
};
</script>
<style scoped>
.child-view {
  height: 100%;
  overflow: hidden;
}
</style>
